package com.cai.kcsj.controller;

import com.cai.kcsj.entity.Comtent;
import com.cai.kcsj.service.ComtentServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @version 1.0
 * @author：蔡松坡
 * @date：2021/1/4 19 : 37
 * @package：com.cai.kcsj.controller
 */
@Controller
@RequestMapping("/comtent")
public class ComtentController {

    @Autowired
    private ComtentServer comtentServer;

    @RequestMapping("/comtent")
    public String selectAllComtent(Model model){
        List<Comtent> comtents = comtentServer.selectComtent();
        model.addAttribute("comtentList",comtents);
        return "conmentmanager";
    }

    @RequestMapping("/delete/{id}")
    public String deleteComtent(@PathVariable("id") Integer id){
        comtentServer.deleteComtent(id);
        return "redirect:/comtent/comtent";
    }


}
